package com.example.mallorder.util;

import com.example.mallorder.constant.OrderConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @author guanglin.ma
 * @date 2024-01-18 18:49
 */
@Component
public class OrderMsgProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void sendOrderMsg(String msg) {
        rocketMQTemplate.syncSend(OrderConstant.ROCKETMQ_ORDER_TOPIC,
                MessageBuilder.withPayload(msg).build(),
                5000,
                4);
    }
}
